/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jsf.service;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

/**
 *
 * @author Admin
 */
@ManagedBean
public class DeleteService {
    
    @ManagedProperty("#{userService}")
    private UserService service;
    
    private String[] selectedName;
    
    private String name;
    
    public void setService(UserService service) {
        this.service = service;
    } 
     
    public void deleteUser(){
        System.out.println("deleteUser do");
        String [] name1 = getSelectedName();
        for (String name11 : name1) {
            System.out.println(name11);
            
        }
        service.deleteUser(getSelectedName());
    }
   
    /**
     * @return the selectedName
     */
    public String[] getSelectedName() {
        return selectedName;
    }

    /**
     * @param selectedName the selectedName to set
     */
    public void setSelectedName(String[] selectedName) {
        this.selectedName = selectedName;
    }

    /**
     * @return the deleteName
     */
    public String getDeleteName() {
        return name;
    }

    /**
     * @param deleteName the deleteName to set
     */
    public void setDeleteName(String deleteName) {
        this.name = deleteName;
    }
    
    public void deleteName(){
        System.out.println(name);
        boolean isOK = service.deleteName(name);
        //service.deleteName("gang");
        System.out.println(isOK);
    }
    
    
    
    
}
